﻿using System;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

namespace TK.Common.BackgroundJob
{
    /// <summary>
    /// 后台任务服务
    /// </summary>
    public interface IBackgroundJobService
    {
        /// <summary>
        /// hostservice 调用
        /// </summary>
        Task Execute(CancellationToken cancellationToken);

        /// <summary>
        /// add background job
        /// </summary>
        /// <typeparam name="IService">注入的服务</typeparam>
        /// <param name="expression">lamada表达式</param>
        void Transfer<IService>(Expression<Func<IService, Task>> expression);

        /// <summary>
        /// add background job
        /// </summary>
        /// <param name="expression">lamada表达式</param>
        void Transfer(Expression<Action> expression);
    }
}
